const gulp = require('gulp');
const html = require('gulp-minify-html');
const css = require('gulp-minify-css');//压缩css的插件
const script = require('gulp-uglify');//压缩js的插件
const babel = require('gulp-babel');//主要
const imagemin = require('gulp-imagemin');
// const watch = require('gulp-watch');


gulp.task('uglifyhtml',() =>{
    return gulp.src('src/html/*.html')
    .pipe(html())
    .pipe(gulp.dest('dist/html'));
});
//3.压缩css
gulp.task('uglifycss', () => {
    return gulp.src('src/style/*.css')
        .pipe(css())//执行压缩
        .pipe(gulp.dest('dist/style'));
});
//4.压缩js
gulp.task('uglifyjs', () => {
    return gulp.src('src/script/*.js')
        .pipe(babel({//先将es6转换成es5
            presets: ['es2015']//es2015->es6  es2016->es7...
        }))
        .pipe(script())//再执行压缩
        .pipe(gulp.dest('dist/script'));
});
//6.图片压缩插件-imagemin@6
//对png最大的压缩，其他的格式几乎压不动。
gulp.task('uglifyimg', () => {
    return gulp.src('src/img/*.{png,gif,jpg,ico}')
        .pipe(imagemin())//执行压缩
        .pipe(gulp.dest('dist/img'));
});
